package com.sskj.mine.presenter;

import com.lzy.okgo.model.Response;
import com.sskj.common.base.HttpData;
import com.sskj.common.util.ToastUtil;
import com.sskj.lib.http.JsonCallBack;
import com.sskj.mine.bean.ImgUrlBean;
import com.sskj.mine.http.HttpConfig;
import com.sskj.mine.ui.activity.PayTypeUpdateActivity;

import java.io.File;


public class PayTypeUpdateActivityPresenter extends BasePresenter<PayTypeUpdateActivity> {


    public void addPayWay(String payId, String payType, String tradePwd, String wxAccount
            , String wxImg, String alipayAccount, String aliImg, String bankCardNo
            , String bankCardOpenBank, String bankCardType, String name, String palAccount) {
        httpService.addPayWay(payId, payType, tradePwd, wxAccount, wxImg, alipayAccount
                , aliImg, bankCardNo, bankCardOpenBank, bankCardType, name, palAccount)
                .execute(new JsonCallBack<HttpData>() {
                    @Override
                    public void onSuccess(Response<HttpData> response) {
                        HttpData httpData = response.body();
                        ToastUtil.showShort(httpData.getMsg());
                        if (httpData.getStatus() == HttpConfig.OK) {
                            mView.addSuccess();
                        }
                    }
                });
    }

    public void uploadImg(File file) {
        httpService.uploadImg(file)
                .execute(new JsonCallBack<HttpData<ImgUrlBean>>(this) {
                    @Override
                    public void onSuccess(Response<HttpData<ImgUrlBean>> response) {
                        HttpData<ImgUrlBean> httpData = response.body();
                        if (httpData.getStatus() == HttpConfig.OK) {
                            mView.uploadSuccess(httpData.getData().getUrl());
                        }
                    }
                });
    }
}
